import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 把token存到vuex
    token: localStorage.getItem('token') || '',
    refresh_token: localStorage.getItem('refresh_token') || ''
  },
  mutations: {
    setToken (state, token) {
      state.token = token
      // 把token存到本地
      localStorage.setItem('token', token)
    },
    setrefreshToken (state, refreshToken) {
      state.refresh_token = refreshToken
      localStorage.setItem('refresh_token', refreshToken)
    }
  },
  actions: {
  },
  modules: {
  }
})
